#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5,inf=1e8;
char op[N];
int l[N],r[N],ans[N];
multiset<pair<int,int>> sl,sr;
//maximize l,minimize r.
//minimize r,maximize l.
multiset<int> vl[N],vr[N];
struct Sgt{
	struct Node{
		int mxl,mnr,ans;
		Node(int x,int y,int z){ mxl=x,mnr=y,ans=z; }
		Node(){ mxl=-inf,mnr=inf,ans=inf; }
		friend Node operator+(const Node &A,const Node& B){
			return Node(max(A.mxl,B.mxl),min(A.mnr,B.mnr),min({A.ans,B.ans,B.mnr-A.mxl+1}));
		}
	} tree[N<<2];
#define ls(p) (p*2)
#define rs(p) (p*2+1)
	void upd(int p,int pos,int l,int r){
		if(l==r){
			if(vl[l].empty()) tree[p].mxl=-inf;
			else tree[p].mxl=-*vl[l].begin();
			if(vr[l].empty()) tree[p].mnr=inf;
			else tree[p].mnr=*vr[l].begin();
			return ;
		}
		int mid=(l+r)/2;
		if(pos<=mid) upd(ls(p),pos,l,mid);
		else upd(rs(p),pos,mid+1,r);
		tree[p]=tree[ls(p)]+tree[rs(p)];
	}
	int qry(){ return tree[1].ans; }
} sgt;
int main(){
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int q;cin>>q;
	for(int i=1;i<=q;i++){
		cin>>op[i];
		cin>>l[i]>>r[i];
		r[i]--;
		if(op[i]=='A'){
			sl.insert(make_pair(-l[i],r[i]));
			sr.insert(make_pair(r[i],-l[i]));
			vr[l[i]].insert(r[i]);
			vl[r[i]].insert(-l[i]);
		}
		else{
			sl.erase(sl.find(make_pair(-l[i],r[i])));
			sr.erase(sr.find(make_pair(r[i],-l[i])));
			vr[l[i]].erase(vr[l[i]].find(r[i]));
			vl[r[i]].erase(vl[r[i]].find(-l[i]));
		}
		sgt.upd(1,l[i],1,N-1),sgt.upd(1,r[i],1,N-1);
		auto pr1=*sl.begin(),pr2=*sr.begin();
		if(-pr1.first<=pr2.first) ans[i]=pr1.second+pr2.second+1;
		else ans[i]=sgt.qry();
		cout<<ans[i]<<"\n";
	}
}
